package cn.quang.search.admin.mapper;

import cn.quang.search.admin.entity.po.SearchConditionTableRelation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author:  Entity Generator
 * @since:  2024-02-28 10:59:41
 */
public interface SearchConditionTableRelationMapper extends BaseMapper<SearchConditionTableRelation> {

    @Select(
            " SELECT * FROM search_condition_table_relation WHERE logic_table_id = #{logicTableId} "
    )
    List<SearchConditionTableRelation> selectByLogicTableId(@Param("logicTableId") long logicTableId);

    @Select(
            " SELECT * FROM search_condition_table_relation WHERE condition_id = #{conditionId} "
    )
    List<SearchConditionTableRelation> selectByConditionId(@Param("conditionId") long conditionId);

    @Select(
            " <script> " +
            "     SELECT * FROM search_condition_table_relation " +
            "     <where> " +
            "       <if test='conditionIds != null and conditionIds.size() > 0'> " +
            "         <foreach collection='conditionIds' item='item' open='AND condition_id IN (' close=')' separator=','> " +
            "           #{item} " +
            "         </foreach> " +
            "       </if> " +
            "     </where> " +
            " </script> "
    )
    List<SearchConditionTableRelation> selectByConditionIds(@Param("conditionIds") List<Long> conditionIds);
}
